﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using TableTypes;
using System.Runtime.Serialization;

namespace Speakup
{
    public enum ClassStatus
    {
        Attended,
        Missed,
        Cancelled,
        Reserved,
        ReservedWaitList,
        Available,
        AvailableWaitList,
        Unknown
    }
    
    [Serializable]
    public class Class
    {
        private int m_classId = 0;
        public int ClassId
        {
            get { return m_classId; }
            set { m_classId = value; }
        }

        private ClassName m_className = null;
        public ClassName ClassName
        {
            get { return m_className; }
            set { m_className = value; }
        }

        private ClassTime m_classTime = null;
        public ClassTime ClassTime
        {
            get { return m_classTime;}
            set { m_classTime = value;}
        }

        private ClassStatus m_classStatus = ClassStatus.Unknown;
        public ClassStatus ClassStatus
        {
            get { return m_classStatus;  }   
            set 
            {
                Modified = false;
                PreviousStatus = value;                
                m_classStatus = value; 
            }
        }

        public ClassStatus DesiredStatus
        {
            set
            {
                if (value == m_classStatus) return;

                if (!Modified)
                {
                    PreviousStatus = m_classStatus;
                    Modified = true;
                }

                m_classStatus = value;

                if (m_classStatus == PreviousStatus)
                {
                    Modified = false;
                }
            }
        }

        private bool m_modified = false;
        public bool Modified 
        {
            get
            {
                return m_modified;
            }
            set
            {
                m_modified = value;
            }
        }

        public ClassStatus PreviousStatus { get; private set; }
        public void CancelModification()
        {
            if (Modified)
            {
                m_classStatus = PreviousStatus;                
                Modified = false;
            }
            
        }
        
        
        
        
        
    }
}
